# coding:utf-8

# 01
# for i in range(2):
#     print(i, end=' ')
# 0 1


# 02 TODO
# def func(s, i, j):
#     if i < j:
#         func(s, i + 1, j - 1)
#         s[i], s[j] = s[j], s[i]
#         print(s)
#
#
# def main():
#     a = [10, 6, 23, -90, 0, 3]
#     func(a, 0, len(a) - 1)
#     for i in range(6):
#         print(a[i])
#
#
# main()

# 03
# import copy
# a = [1, 2, 3, 4, ['a', 'b']]
# b = a
# c = copy.copy(a)
# d = copy.deepcopy(a)
# a.append(5)
# a[4].append('c')
# print(a)
# print(b)
# print(c)
# print(d)
# [1, 2, 3, 4, ['a', 'b', 'c'], 5]
# [1, 2, 3, 4, ['a', 'b', 'c'], 5]
# [1, 2, 3, 4, ['a', 'b', 'c']]
# [1, 2, 3, 4, ['a', 'b']]


# 04
# print(type(1/2))  # <class 'float'>

# 05
# print(__name__)  # __main__


# 01
# str1 = "Hello,Python"
# str2 = "Python"
# print(str1.index(str2))

# 04
# class A(object):
#     pass
#
#
# class B(A):
#     pass
#
#
# class C(object):
#     pass
#
#
# class D(B, C):
#     pass
#
#
# b = B()
#
# print(isinstance(b, A))
# print(isinstance(b, object))
# print(isinstance(B, A))
# print(isinstance(b, B))
# True
# True
# False
# True

# print()
# 02
kvps = {'1': 1, '2': 2}
theCopy = kvps.copy()
kvps['1'] = 5
sum = kvps['1'] + theCopy['1']
print(sum)  # 6
# 这里的 kvps.copy()指的是浅拷贝，kvps['1'] 和theCopy['1']原本指向的都是1，
# 但是因为int是不可变的的，所以kvps['1']=5，
# 使得kvps['1']更改指向了，但是theCopy指向的1是int，本身没有改变也不能改变，所以还是1

# 03 TODO
import random
def foo(n):
     random.seed()
     c1 = 0
     c2 = 0
     for i in range(n):
        x = random.random()
        y = random.random()
        r1 = x * x + y * y
        r2 = (1 - x) * (1 - x) + (1 - y) * (1 - y)
        if r1 <= 1 and r2 <= 1:
           c1 += 1
        else:
           c2 += 1
     return  c1 / c2
